package com.jicheng.mapper;

import com.jicheng.dto.task.PagingTemplateParams;
import com.jicheng.dto.task.TemplateDto;
import com.jicheng.dto.task.TemplateFileDto;
import com.jicheng.entity.TemplateLibrary;
import com.jicheng.framework.mybatis.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @ClassName: TemplateLibraryMapper
 * @Description: TODO
 * @author: khz
 * @date: 2020年09月24日 15:15
 */
@Repository
public interface TemplateLibraryMapper extends BaseMapper<TemplateLibrary> {
    @Select("select count(1) from tb_template_library where id = #{id}")
    int isExist(@Param("id") String id);

    /**
     * 获取模板库列表
     * @param params
     * @return
     */
    List<TemplateDto> getTempLibList(PagingTemplateParams params);

    /**
     * 根据id查看模板
     * @param id
     * @return
     */
    @Select("select name fileName,path file,create_time createTime  from tb_template_library where id = #{id} ")
    TemplateFileDto getTempLibDetail(@Param("id") String id);

    /**
     * 删除模板库中的模板
     * @param id
     */
    @Delete("delete from tb_template_library where id = #{id}")
    void delTemplLib(@Param("id") String id);
}
